// 设备管理
import request from '@/utils/request'

/**
 * 搜索售货机(售货机列表)
 * @param {*} params
 * @returns
 */
export const getSearchVendingAPI = (pageIndex, pageSize, innerCode) => request({
  url: '/vm-service/vm/search',
  params: {
    pageIndex,
    pageSize,
    innerCode
  }
})

// 点位搜索
export const getNodeSearchAPI = (params) => request({
  url: '/vm-service/node/search',
  params
})

/**
 * 售货机类型
 * @param {*} params
 * @returns
 */
export const VendingTypeAPI = (params) => request({
  url: '/vm-service/vmType/search',
  params
})

// 新增售货机

export const addVendingAPI = (vmType, nodeId, createUserId) => request({
  url: '/vm-service/vm',
  method: 'POST',
  data: {
    vmType,
    nodeId,
    createUserId
  }
})

/**
 * 查询售货机策略
 * @param {*} id
 * @returns
 */
// 查询售货机策略
export const getQueryVendingAPI = (id) => request({
  url: `vm-service/policy/vmPolicy/${id}`
})

/**
 * 策略列表数据
 * @returns
 */
// 策略列表数据
export const amendStrategyAPI = () => request({
  url: `/vm-service/policy`
})

// 批量列表数据提交（单个）
/**
 * 批量列表数据提交（单个）
 * @returns
 */
export const strategySubmitAPI = (innerCodeList, policyId) => request({
  url: '/vm-service/vm/applyPolicy',
  method: 'PUT',
  data: {
    innerCodeList,
    policyId
  }
})

// 取消策略
export const delStrategyAPI = (innerCode, policyId) => request({
  url: `/vm-service/vm/cancelPolicy/${innerCode}/${policyId}`,
  method: 'PUT'
})

// 点位搜索
export const getAmendNodeSearchAPI = (pageIndex, pageSize) => request({
  url: '/vm-service/node/search',
  params: {
    pageIndex,
    pageSize
  }
})

// 修改售货机点位

export const getAmendVendingNodeAPI = (id, nodeId) => request({
  url: `/vm-service/vm/${id}/${nodeId}}`,
  method: 'PUT'
  // params: {
  //   id,
  //   nodeId
  // }
})

export const channelListAPI = (innerCode) => request({
  url: `/vm-service/channel/channelList/${innerCode}`
})
export const businessTopAPI = (businessId) => request({
  url: `/vm-service/sku/businessTop10/${businessId}`
})
export const skuSearchAPI = (pageIndex, pageSize, skuName) => request({
  url: `/vm-service/sku/search`,
  params: {
    pageIndex,
    pageSize,
    skuName
  }
})
